/**
 * Created by Mikey on 2017/9/18.
 */
import axios from 'axios'
import {Loading} from 'element-ui'
// const Host = 'https://www.v2ex.com/api';
// const Host =process.env.NODE_ENV === 'production' ? 'https://www.v2ex.com/api' : 'http://localhost:8081';

export function Ajax(url,method,data,target) {
  return new Promise((resolve, reject)=> {
    let loading = Loading.service({ target:target,text: '努力加载中' });
    axios({
      url : url,
      method : method,
      data : data,
    })
    .then(response => {
      resolve(response.data);
      loading.close();
    })
  })
}
